phrase = input()
brack_open = "([{<"
brack_close = ")]}>"
mystack = []
brackets_match = True
for char in phrase:
    if char in brack_open:
        mystack.append(char)
    if char in brack_close:
        if len(mystack) == 0 or brack_close.find(char) != brack_open.find(mystack.pop()):
            brackets_match = 0
            break
print(len(mystack) == 0 and brackets_match)
